package com.booking.springrestful.controller;

import com.booking.springrestful.domain.Timeslot;
import com.booking.springrestful.domain.request.timeCheckRequest;
import com.booking.springrestful.domain.request.timeSlotRequest;
import com.booking.springrestful.resp.ResponseResult;
import com.booking.springrestful.service.TimeslotService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/timeslot")
public class timeSlotController {

    @Resource
    private TimeslotService timeslotService;


    //插入时间段数据
    @PostMapping("/add")
    private ResponseResult addTimeslot(@RequestBody List<Timeslot> list){
        timeslotService.addTimeslot(list);
        return ResponseResult.success();
    }


    //根据咨询室id查询时间段
    @GetMapping("/getById")
    private ResponseResult<List<Timeslot>> getTimeslotById(Integer id){
        List<Timeslot> timeslot= timeslotService.getTimeslotById(id);
        return ResponseResult.success(timeslot);
    }


    @PostMapping("/update")
    private ResponseResult updateTimeslot(@RequestBody timeSlotRequest timeSlotRequest){
        timeslotService.updateTimeslot(timeSlotRequest.getList(),timeSlotRequest.getConsultationRoomId());
        return ResponseResult.success();
    }

    //删除所有时间段然后置0
    @PostMapping("/checkTime")
    private ResponseResult checkTime(@RequestBody timeCheckRequest timeCheckRequest){
        timeslotService.checkTime(timeCheckRequest.getId());
        return ResponseResult.success();
    }


}
